<!DOCTYPE html>
<html lang="zh-CN">

<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <!-- 上述3个meta标签*必须*放在最前面，任何其他内容都*必须*跟随其后！ -->
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0,user-scalable=no,minimal-ui">
    <meta name="description" content="">
    <meta name="author" content="">
    <link rel="icon" href="../img/asset-favico.ico">
    <title>健康档案详情</title>

    <link rel="stylesheet" href="../css/page-health-recordDetail.css" />
</head>

<body data-spy="scroll" data-target="#myNavbar" data-offset="150">
<div id="app">
    <!-- 页面头部 -->
    <div class="top-header">
        <span class="f-left"><i class="icon-back"></i><a href="health-record.html" style="color: white">返回</a></span>
        <span class="center">千锋健康</span>
        <span class="f-right"><i class="icon-more"></i></span>
    </div>
    <!-- 页面内容 -->
    <div class="contentBox" >
        <div class="list-content">
            <div class="fix-info">
                <ul class="list-unstyled ">
                    <li><span class="tit">档案号</span><span class="info">{{user.number}}</span></li>
                    <li><span class="tit">姓名</span><span class="info">{{user.name}}</span></li>
                    <li><span class="tit">兄弟姐妹状态</span><span class="info">{{user.brother}}</span></li>
                    <li><span class="tit">父母状况</span><span class="info">{{user.parents}}</span></li>
                    <li><span class="tit">有无家族病史</span><span class="info">{{user.health}}</span></li>
                </ul>
            </div>

        </div>
    </div>
</div>
<!-- 页面 css js -->
<!-- <script src="health-index.js"></script> -->
</body>
<script src="../js/vue.js"></script>
<script src="../js/axios-0.18.0.js"></script>
<script>
    new Vue({
        el:"#app",
        data:{
            // 存放用户信息
            user: {}
        },
        mounted() {
            this.findUser();
        },
        methods:{
            findUser() {
                axios.defaults.withCredentials = true;
                axios({
                    url: "http://localhost:81/infor/first",
                    method: "post",
                    headers: {
                        "Authorization": "Bearer " + localStorage.getItem("token")
                    }
                }).then(resp=>{
                    this.hasToken(resp)
                    let result = resp.data;
                    if (result.code === 1000) {
                        this.user = result.data;
                    }
                })
            },
            hasToken(resp) {
                let refreshToken = resp.headers.refresh_token;
                if (refreshToken!=null&&refreshToken.length!=0){
                    localStorage.setItem("token",refreshToken)
                }
                let res = resp.data;
                if (res.code == 2000){
                    //没有登录  -- 跳转到登录页面
                    location.href = "./health-login.html"
                }else if(res.code == 3000){
                    //没有权限
                    alert(res.msg)
                }else if(res.code == 1000){
                    //访问数据成功
                    this.msg = res;
                }
            }
        }
    })
</script>